
#import <UIKit/UIKit.h>
@protocol IDvDocViewer;
@protocol IDvRootViewEventListener;
@protocol IContainerEventListener;
@protocol IDmDocEventListener;
@class DvRootView;
@class DvContainerScrollView;
@class DvOverlayView;
@class DvCache;

NS_ASSUME_NONNULL_BEGIN
@interface DvDocViewer : NSObject<IDvDocViewer, IDvRootViewEventListener, IContainerEventListener, IDmDocEventListener>

@property (nonatomic, retain) DvCache *cache;
@property (nonatomic, retain) DvRootView *rootView;
@property (nonatomic, retain) DvContainerScrollView *pageContainer;
@property (nonatomic, retain) DmDocument *document;
@property (nonatomic, retain) DvReadingStatus *readingStatus;
@property (nonatomic, assign) int bottomOffset;
@property (nonatomic, assign) BOOL scrollDirectionalLocked;
@property (nonatomic, assign) BOOL zoomLocked;
@property (nonatomic, assign) BOOL screenLocked;
@property (nonatomic, assign) BOOL scrollDisabled;
@property (nonatomic, assign) BOOL doubleTapDisabled;
@property (nonatomic, strong, nullable) NSMutableArray<IGestureEventListener>* guestureEventListeners;
@property (nonatomic, assign) BOOL PageManageEdit;

- (void)setBottomOffset:(int)offset;

- (UIView *)getRootView;
- (id<IDvPageView>)getPageView:(int)index;
- (int)getCurrentPage;
- (PDF_LAYOUT_MODE)getPageLayoutMode;
- (CGRect)calculateContainerFrame;

- (CGRect)convertPageViewRectToDisplayViewRect:(CGRect)rect pageIndex:(int)index;
- (CGPoint)convertDisplayViewPtToPageViewPt:(CGPoint)point pageIndex:(int)index;
- (CGRect)convertDisplayViewRectToPageViewRect:(CGRect)rect pageIndex:(int)index;

- (CGPoint)docViewerToPageViewPoint:(CGPoint)point pageIndex:(int)index;
- (CGRect)pageViewToDocViewerRect:(CGRect)rect pageIndex:(int)index;
- (CGRect)docViewerToPageViewRect:(CGRect)rect pageIndex:(int)index;

- (void)registerPageEventListener:(id<IDvPageEventListener>)listener;
- (void)unregisterPageEventListener:(id<IDvPageEventListener>)listener;

- (void)registerVCPageEventListener:(id<IPageEventListener>)listener;
- (void)unregisterVCPageEventListener:(id<IPageEventListener>)listener;

- (void)registerVCUserInteractionListener:(id<IUserInteractionListener>)listener;
- (void)unregisterVCUserInteractionListener:(id<IUserInteractionListener>)listener;

- (void)registerVCScrollViewListener:(id<IScrollViewEventListener>)listener;
- (void)unregisterVCScrollViewListener:(id<IScrollViewEventListener>)listener;

- (void)registerTouchEventListener:(id<IDvTouchEventListener>)listener;
- (void)unregisterTouchEventListener:(id<IDvTouchEventListener>)listener;


- (void)onUserInteraction;
- (BOOL)onTap:(UITapGestureRecognizer *)recognizer;
- (BOOL)onLongPress:(UILongPressGestureRecognizer *)recognizer;

- (void)onScrollViewDidScroll:(UIScrollView *)scrollView;
- (void)onScrollViewDidZoom:(UIScrollView *)scrollView;
- (void)onScrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)onScrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
- (void)onScrollViewWillBeginDecelerating:(UIScrollView *)scrollView;
- (void)onScrollViewDidEndDecelerating:(UIScrollView *)scrollView;

- (void)onScrollViewWillBeginZooming:(UIScrollView *)scrollView;
- (void)onScrollViewDidEndZooming:(UIScrollView *)scrollView;

- (void)onDrawPageViewToOverlayView:(id<IDvPageView>)pageView inContext:(CGContextRef)context;
- (void)onDrawDocViewerToOverlayView:(DvOverlayView*)overlayView context:(CGContextRef)context clipBox:(CGRect)clipBox;

- (void)setIsNightMode:(BOOL)isNight;
- (void)setBackgroundColor:(UIColor*)color;
- (void)setDoubleTapDisabled:(BOOL)disabled;

/// 获取当前page 缩略图
/// @param pageIndex page
/// @param targetSize 目标size ，如果width/height 均为0 则按照之前的逻辑
/// @param queue 队列
/// @param handler handler
- (void)docViewThumbnailForPage:(int)pageIndex
                     targetSize:(CGSize)targetSize
                  dispatchQueue:(dispatch_queue_t)queue
                    withHandler:(getThumbnailHandler)handler;

/// 更新 themeColor
- (void)updateThemeColors;
/// 退出页面管理
- (void)exitPageManageUI;
@end

NS_ASSUME_NONNULL_END
